package org.lyl.taobao.controller;

import org.lyl.taobao.api.IShopCartService;
import org.lyl.taobao.service.ShopCartServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: Re
 * @Date: 2021/4/8 17:09
 */
@WebServlet("/deleteShopCart")
public class DeleteShopCartServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer userId = Integer.parseInt(req.getParameter("userId"));
        Integer c_Id = Integer.parseInt(req.getParameter("c_Id"));
        IShopCartService iShopCartService = new ShopCartServiceImpl();
        if (iShopCartService.deleteShopCart(userId,c_Id)) {
            req.setAttribute("msg","删除成功");
        } else {
            req.setAttribute("msg","删除失败");
        }
        req.getRequestDispatcher("collect.jsp").forward(req,resp);
    }
}
